package edu.umd.mhealth.lab5;

import org.scribe.model.Token;

import android.os.Bundle;
import android.content.Intent;
import android.support.v4.app.FragmentActivity;
import android.widget.Toast;

public class MainActivity extends FragmentActivity {
	protected Token accessToken; // DO NOT CHANGE

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		/* DO NOT CHANGE */
		if (savedInstanceState != null){
			accessToken = (Token) savedInstanceState.getSerializable("accessToken");
			
		}
	}

		
	/* DO NOT CHANGE */
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		// checking which device has returned from OAuth authentication
		Bundle result = data.getExtras();
		if (result == null){
			Toast.makeText(getApplicationContext(), "login failed", 30);
		}else {
			accessToken = (Token) result.getSerializable("accessToken");
		}
	}
	
	/* DO NOT CHANGE */
	@Override
	protected void onSaveInstanceState(Bundle outState){
		super.onSaveInstanceState(outState);	
		outState.putSerializable("accessToken", accessToken);
	}


}
